package com.heima.wemedia.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

@Configuration
public class UploadConfig {

    @Bean
    public MultipartConfigElement multipartConfigElement(){
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //单个文件最大值  默认是1m     设置为10m
        factory.setMaxFileSize(DataSize.ofBytes(10485760));
        //上传数据总大小，默认1m
        factory.setMaxRequestSize(DataSize.ofBytes(10485760));

        return factory.createMultipartConfig();
    }
}
